<?php

class CompetitorListPanel extends QPanel {
    // Local instance of the Meta DataGrid to list Competitors
    public $dtgCompetitors;
    public $pnlCompetitorEdit;

    // Other public QControls in this panel
    public $btnCreateNew;
    public $pxyEdit;

    // Callback Method Names
    protected $strCloseEditPanelMethod;

    public function __construct($objParentObject,  $strCloseEditPanelMethod, $strControlId = null) {
        // Call the Parent
        try {
            parent::__construct($objParentObject, $strControlId);
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }

        // Record Method Callbacks

        $this->strCloseEditPanelMethod = $strCloseEditPanelMethod;

        // Setup the Template
        $this->strTemplate = __DOCROOT__. __MARKETING__ . '/tpl/CompetitorListPanel.tpl.php';
        $this->pnlCompetitorEdit = new CompetitorEditPanel($this,'ClosePanel');

        // Instantiate the Meta DataGrid
        $this->dtgCompetitors = new CompetitorDataGrid($this);

        // Style the DataGrid (if desired)
        $this->dtgCompetitors->CssClass = 'datagrid';
        $this->dtgCompetitors->AlternateRowStyle->CssClass = 'alternate';

        // Add Pagination (if desired)
        $this->dtgCompetitors->Paginator = new QPaginator($this->dtgCompetitors);
        $this->dtgCompetitors->ItemsPerPage = 6;

        // Use the MetaDataGrid functionality to add Columns for this datagrid



        // Create the Other Columns (note that you can use strings for com_competitor's properties, or you
        // can traverse down QQN::com_competitor() to display fields that are down the hierarchy)
        $this->dtgCompetitors->MetaAddColumn('Date');
        $this->dtgCompetitors->MetaAddColumn(QQN::Competitor()->Competitor);
        $this->dtgCompetitors->MetaAddColumn('Notes');
        $this->dtgCompetitors->MetaAddColumn(QQN::Competitor()->EuserObject);

        $this->dtgCompetitors->AdditionalConditions = QQ::Equal(QQN::Competitor()->SchoolId, $_SESSION['Org']->Id) ;


    }
        public function CloseReOpenEditPanel() {
        $this->pnlCompetitorEdit->RemoveChildControls(true);
        $this->pnlCompetitorEdit->Visible = false;
        $this->pnlCompetitorEdit = New CompetitorEditPanel($this,'ClosePanel');
        $this->pnlCompetitorEdit->Visible = true;
    }

}
?>